package com.pr.sentinel;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import org.springframework.stereotype.Service;

/**
 * @description:
 * @projectName:spring-skill
 * @see:com.pr.sentinel
 * @author:LXC
 * @createTime:2024/7/19 15:12
 * @version:1.0
 */
@Service
public class TestService {

    int i=0;

    @SentinelResource(value="sayHello",fallback = "sayHelloFail")
    public String sayHello(String name){
        String result ="";
        if(i++%3==0){
            return "false";
        }else {
            return "Hello,"+name;
        }
    }

    public String sayHelloFail(String name){
        return "呼叫失败:"+name;
    }
}
